package Song.Han.day09.demo01;

import java.util.Date;

public class Demo02Date {
    public static void main(String[] args) {
        demo01();
        System.out.println("--------------------------");
        demo02();
    }

    public static void demo01(){
        //空参数的构造函数，Date()获取当前系统的日期和时间
        Date date = new Date();
        System.out.println(date);//Tue Nov 03 11:14:14 CST 2020
    }

    public static void demo02(){
        //Date(long date):传递毫秒值，把毫秒转换成Date日期
        Date date1 = new Date(0L);
        System.out.println(date1);//Thu Jan 01 08:00:00 CST 1970


        long ms1 = System.currentTimeMillis();
        long ms2 = new Date().getTime();//用法等同System.currentTimeMillis
        System.out.println(ms1);
        System.out.println(ms2);

        Date date2 = new Date(ms1);
        System.out.println(date2);//Tue Nov 03 11:14:14 CST 2020

    }
}
